package component;

import group.GeoGroup;

public class Structure {

	private final GeoGroup permanentComponents;
	private final GeoGroup temporaryComponents;
	private final GeoGroup nonpickableComponents;
	
	@Deprecated
	public Structure(GeoGroup permanentComponents, GeoGroup temporaryComponents) {
		this(permanentComponents, temporaryComponents, null);
	}
	
	public Structure(GeoGroup permanentComponents, GeoGroup temporaryComponents, GeoGroup nonpickableComponents) {
		this.permanentComponents = permanentComponents;
		this.temporaryComponents = temporaryComponents;
		this.nonpickableComponents = nonpickableComponents;
	}
	
	public void addTemporaryComponent(AbstractComponent component) {
		component.attachToScene(temporaryComponents);
	}
	
	public void addPermanentComponent(AbstractComponent component) {
		component.attachToScene(permanentComponents);
	}
	
	public void addNonpickable(AbstractComponent component) {
		component.attachToScene(nonpickableComponents);
	}
	
	public void transferToPermanent(AbstractComponent component) {
		component.detachFromScene();
		this.addPermanentComponent(component);
	}
	
	public void transferToTemporary(AbstractComponent component) {
		component.detachFromScene();
		this.addTemporaryComponent(component);
	}
	
	public void transferToNonpickable(AbstractComponent component) {
		component.detachFromScene();
		this.addNonpickable(component);
	}
	
	public boolean isTemporary(AbstractComponent component) {
		return component.isInGroup(temporaryComponents);
	}
	
	public boolean isPermanent(AbstractComponent component) {
		return component.isInGroup(permanentComponents);
	}
	
	public void clearTemporaryComponents() {
		temporaryComponents.removeAllChildren();
	}

	public GeoGroup getPermanentGeoGroup() {
		return permanentComponents;
	}
	
}
